﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="CATechProc.CustomMenuItem.NotifyChangeDocument"
                RegistrationType="List"
                RegistrationId="22005"
                Location="EditControlBlock"
                ImageUrl="/_layouts/Images/CreditAgricole/CAMail16.png"
                Sequence="600"
                Title="Send Notification"
                Description="Notify people by e-mail that the selected document should be updated.">
    <UrlAction Url="javascript:alert('Not yet implemented.');" />
  </CustomAction>
  
  <CustomAction Id="Ribbon.Documents.NotifyChangeDocument"
                Location="CommandUI.Ribbon"
                RegistrationType="List"
                RegistrationId="22005">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Groups._children">
          <Group Id="Ribbon.Documents.NotifyChangeDocument"
                 Title="Crédit Agricole"
                 Description="Document Notification"
                 Sequence="25"
                 Template="Ribbon.Templates.CATemplate">
            <Controls Id="Ribbon.Documents.NotifyChangeDocument.Controls">
              <Button Id="Ribbon.Documents.NotifyChangeDocument.CATechProcSendMail"
                      LabelText="Send Notification"
                      Description="Notify people by e-mail that the selected document should be updated."
                      ToolTipDescription="Notify people by e-mail that the selected document should be updated."
                      ToolTipTitle="Send Notification"
                      TemplateAlias="o1"
                      Sequence="15"
                      Image16by16="/_layouts/Images/CreditAgricole/CAMail16.png"
                      Image32by32="/_layouts/Images/CreditAgricole/CAMail32.png"
                      Command="NotifyChangeDocument.OnSendMail" />
            </Controls>
          </Group>
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Documents.Scaling._children">
          <MaxSize Id="Ribbon.Documents.Scaling.NotifyChangeDocument.MaxSize"
                   GroupId="Ribbon.Documents.NotifyChangeDocument"
                   Size="CAOneRowLarge"
                   Sequence="15" />
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Templates._children">
          <GroupTemplate Id="Ribbon.Templates.CATemplate">
            <Layout Title="CAOneRowLarge">
              <Section Type="OneRow">
                <Row>
                  <ControlRef DisplayMode="Large" TemplateAlias="o1" />
                </Row>
              </Section>
            </Layout>
          </GroupTemplate>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="NotifyChangeDocument.OnSendMail"
                          CommandAction="javascript:alert('Send Notification - Not yet implemented.');"
                          EnabledScript="javascript:
                                            function checkIsEnabled()
                                            {
                                              var context = SP.ClientContext.get_current();
                                              var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
                                              var count = CountDictionary(selectedItems);
                                              if (count == 1)
                                              {
                                                // Get List Guid
                                                //var listGuid = SP.ListOperation.Selection.getSelectedList();
                                                // Get corresponding list from context
                                                //var web = context.get_web();
                                                //var list = web.get_lists().getById(listGuid);
                                                // get item by Id
                                                //var item = list.getItemById(selectedItems[0].id);
                                                //context.load(item,'Titre');
                                                
                                                return true;  
                                              }
                                              else
                                              {
                                                return false;
                                              }
                                            };
                                            checkIsEnabled();"/>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
